#ifndef __X_DYNLIB_H__
#define __X_DYNLIB_H__

#ifdef _WIN32

#include <windows.h>

#define DL_HANDLER HMODULE
#define DL_OPEN(path) LoadLibrary("./" path ".dll")
#define DL_CLOSE(handle) FreeLibrary(handle)
#define DL_GET_SYM(handle, name) GetProcAddress(handle, name)
#define DL_HANDLER_IS_OK(handle) (handle > 0)
 
#else

#include <dlfcn.h>

#define DL_HANDLER void*
#define DL_OPEN(path) dlopen("./" path ".so", RTLD_LAZY)
#define DL_CLOSE(handle) dlclose(handle)
#define DL_GET_SYM(handle, name) dlsym(handle, name)
#define DL_HANDLER_IS_OK(handle) (handle != NULL)

#endif /*__WIN32*/


#endif /*__X_DYNLIB_H__*/
